/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.sidora.opcit;

import java.io.Serializable;
import java.util.logging.Logger;
import javax.swing.UIManager;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
import org.openide.util.Utilities;

/**
 * Top component which displays something.
 */
final class OpcitTopComponent extends TopComponent {

    private static OpcitTopComponent instance;
    /** path to the icon used by the component and its open action */
    static final String ICON_PATH = "org/sidora/opcit/resources/Books32.png";

    private static final String PREFERRED_ID = "OpcitTopComponent";

    private OpcitTopComponent() {
        System.setProperty(
            "Quaqua.tabLayoutPolicy","wrap"
         );
         // set the Quaqua Look and Feel in the UIManager
         try { 
              UIManager.setLookAndFeel(
                  "ch.randelshofer.quaqua.QuaquaLookAndFeel"
              );
         // set UI manager properties here that affect Quaqua
         
         } catch (Exception e) {
             // take an appropriate action here
             
         }
        initComponents();
        setName(NbBundle.getMessage(OpcitTopComponent.class, "CTL_OpcitTopComponent"));
        setToolTipText(NbBundle.getMessage(OpcitTopComponent.class, "HINT_OpcitTopComponent"));
        setIcon(Utilities.loadImage(ICON_PATH, true));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelTop = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton1.putClientProperty(

            "Quaqua.Button.style", "placard"

        );
        jButton2 = new javax.swing.JButton();
        jButton2.putClientProperty(

            "Quaqua.Button.style", "placard"

        );
        jButton3 = new javax.swing.JButton();
        jButton3.putClientProperty(

            "Quaqua.Button.style", "placard"

        );
        jButton4 = new javax.swing.JButton();
        jButton4.putClientProperty(

            "Quaqua.Button.style", "placard"

        );
        jButton5 = new javax.swing.JButton();
        jButton5.putClientProperty(

            "Quaqua.Button.style", "placard"

        );
        jButton6 = new javax.swing.JButton();
        jButton6.putClientProperty(

            "Quaqua.Button.style", "placard"

        );
        jScrollPaneTable = new javax.swing.JScrollPane();
        jTableReference = new javax.swing.JTable();
        jTableReference.putClientProperty(

            "Quaqua.Table.style", "striped"

        );

        jButton1.setFont(new java.awt.Font("Dialog", 0, 9)); // NOI18N
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sidora/opcit/resources/Search32.png"))); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(OpcitTopComponent.class, "OpcitTopComponent.jButton1.text")); // NOI18N
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setIconTextGap(1);
        jButton1.setMaximumSize(new java.awt.Dimension(58, 57));
        jButton1.setMinimumSize(new java.awt.Dimension(58, 57));
        jButton1.setPreferredSize(new java.awt.Dimension(58, 57));
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setFont(new java.awt.Font("Dialog", 0, 9));
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sidora/opcit/resources/Note32.png"))); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jButton2, org.openide.util.NbBundle.getMessage(OpcitTopComponent.class, "OpcitTopComponent.jButton2.text")); // NOI18N
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton2.setIconTextGap(1);
        jButton2.setMaximumSize(new java.awt.Dimension(58, 57));
        jButton2.setMinimumSize(new java.awt.Dimension(58, 57));
        jButton2.setPreferredSize(new java.awt.Dimension(58, 57));
        jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        jButton3.setFont(new java.awt.Font("Dialog", 0, 9));
        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sidora/opcit/resources/Bulb32.png"))); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jButton3, org.openide.util.NbBundle.getMessage(OpcitTopComponent.class, "OpcitTopComponent.jButton3.text")); // NOI18N
        jButton3.setFocusable(false);
        jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton3.setIconTextGap(1);
        jButton3.setMaximumSize(new java.awt.Dimension(58, 57));
        jButton3.setMinimumSize(new java.awt.Dimension(58, 57));
        jButton3.setPreferredSize(new java.awt.Dimension(58, 57));
        jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        jButton4.setFont(new java.awt.Font("Dialog", 0, 9));
        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sidora/opcit/resources/Ref32.png"))); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jButton4, org.openide.util.NbBundle.getMessage(OpcitTopComponent.class, "OpcitTopComponent.jButton4.text")); // NOI18N
        jButton4.setFocusable(false);
        jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton4.setIconTextGap(1);
        jButton4.setMaximumSize(new java.awt.Dimension(58, 57));
        jButton4.setMinimumSize(new java.awt.Dimension(58, 57));
        jButton4.setPreferredSize(new java.awt.Dimension(58, 57));
        jButton4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        jButton5.setFont(new java.awt.Font("Dialog", 0, 9));
        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sidora/opcit/resources/Settings32.png"))); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jButton5, org.openide.util.NbBundle.getMessage(OpcitTopComponent.class, "OpcitTopComponent.jButton5.text")); // NOI18N
        jButton5.setFocusable(false);
        jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton5.setIconTextGap(1);
        jButton5.setMaximumSize(new java.awt.Dimension(58, 57));
        jButton5.setMinimumSize(new java.awt.Dimension(58, 57));
        jButton5.setPreferredSize(new java.awt.Dimension(58, 57));
        jButton5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        jButton6.setFont(new java.awt.Font("Dialog", 0, 9));
        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sidora/opcit/resources/output32.png"))); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(jButton6, org.openide.util.NbBundle.getMessage(OpcitTopComponent.class, "OpcitTopComponent.jButton6.text")); // NOI18N
        jButton6.setFocusable(false);
        jButton6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton6.setIconTextGap(1);
        jButton6.setMaximumSize(new java.awt.Dimension(58, 57));
        jButton6.setMinimumSize(new java.awt.Dimension(58, 57));
        jButton6.setPreferredSize(new java.awt.Dimension(58, 57));
        jButton6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        javax.swing.GroupLayout jPanelTopLayout = new javax.swing.GroupLayout(jPanelTop);
        jPanelTop.setLayout(jPanelTopLayout);
        jPanelTopLayout.setHorizontalGroup(
            jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTopLayout.createSequentialGroup()
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(42, 42, 42)
                .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(33, 33, 33)
                .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(118, Short.MAX_VALUE))
        );
        jPanelTopLayout.setVerticalGroup(
            jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 70, Short.MAX_VALUE)
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jTableReference.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Lafuente et al.", "1993", "Los hechos que nos llevaron a concluir", "RAP^"},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Author", "Year", "Title", "Volume"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPaneTable.setViewportView(jTableReference);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanelTop, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(22, 22, 22))
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jScrollPaneTable, javax.swing.GroupLayout.DEFAULT_SIZE, 611, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanelTop, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPaneTable, javax.swing.GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JPanel jPanelTop;
    private javax.swing.JScrollPane jScrollPaneTable;
    private javax.swing.JTable jTableReference;
    // End of variables declaration//GEN-END:variables
    /**
     * Gets default instance. Do not use directly: reserved for *.settings files only,
     * i.e. deserialization routines; otherwise you could get a non-deserialized instance.
     * To obtain the singleton instance, use {@link findInstance}.
     */
    public static synchronized OpcitTopComponent getDefault() {
        if (instance == null) {
            instance = new OpcitTopComponent();
        }
        return instance;
    }

    /**
     * Obtain the OpcitTopComponent instance. Never call {@link #getDefault} directly!
     */
    public static synchronized OpcitTopComponent findInstance() {
        TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
        if (win == null) {
            Logger.getLogger(OpcitTopComponent.class.getName()).warning(
                    "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");
            return getDefault();
        }
        if (win instanceof OpcitTopComponent) {
            return (OpcitTopComponent) win;
        }
        Logger.getLogger(OpcitTopComponent.class.getName()).warning(
                "There seem to be multiple components with the '" + PREFERRED_ID +
                "' ID. That is a potential source of errors and unexpected behavior.");
        return getDefault();
    }

    @Override
    public int getPersistenceType() {
        return TopComponent.PERSISTENCE_ALWAYS;
    }

    @Override
    public void componentOpened() {
        // TODO add custom code on component opening
    }

    @Override
    public void componentClosed() {
        // TODO add custom code on component closing
    }

    /** replaces this in object stream */
    @Override
    public Object writeReplace() {
        return new ResolvableHelper();
    }

    @Override
    protected String preferredID() {
        return PREFERRED_ID;
    }

    final static class ResolvableHelper implements Serializable {

        private static final long serialVersionUID = 1L;

        public Object readResolve() {
            return OpcitTopComponent.getDefault();
        }
    }
}
